﻿
function Sample01_Default() {};

Sample01_Default.prototype.main = function() {

    this.AddHandler(this.btnCall, "click", this.Call);
    
}

Sample01_Default.prototype.Call = function() {

    // Creating and defining a callback method...
    var telephone = new Telephone(this.CreateHandler(this.CallBackRinging));

    telephone.ringing();

}

Sample01_Default.prototype.CallBackRinging = function() {
    alert("The telefone is ringing. \n The word 'this' refers to the page? " + (this == Page));
}

// Example of object that requires a callback method...
function Telephone(callBack) 
{ 
    this.callBackRinging = callBack;
};

Telephone.prototype.ringing = function() {

    // The telephone is ringing...

    //If there is a callback method...
    if (this.callBackRinging)
        this.callBackRinging();

};